<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="UTF-8">
	<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
	<meta http-equiv="X-UA-Compatible" content="ie=edge">
	<title>邀请记录</title>
	<link rel="stylesheet" href="/index/css/common.css?v=2">
	<link rel="stylesheet" href="/index/css/invite.css?v=2">
	<style>

	</style>
</head>
<body>
	<div class="tabsBox">
		<div class="topTab">
			<div class="tabLeft">
				<img src="/index/assets/left.png" >
			</div>
			<div class="tabCenter">邀请记录</div>
			<div class="tabRight">邀请说明</div>
		</div>
	</div>
	<div class="invite">
		<div class="tabList">
			<div class="tabs on">邀请成功({$invite['success']})</div>
			<div class="tabs">邀请中({$invite['wait']})</div>
		</div>
		<div class="copyPhone">复制电话联系您的下级建立私域团队</div>
		<!-- 邀请成功 -->
		<div class="listBox active invite1">
			<!--<div class="listDetail">-->
				<!--<div class="list_t cleardrift">-->
					<!--<div class="t_name">admin</div>-->
					<!--<div class="t_time">12-12 10:22</div>-->
				<!--</div>-->
				<!--<div class="list_c cleardrift">-->
					<!--<div class="c_phone">12</div>-->
					<!--<div class="c_copy" onclick="copy">复制</div>-->
				<!--</div>-->
				<!--<div class="list_b cleardrift">-->
					<!--<div class="b_guanxi"><span>与我关系</span>: 直接</div>-->
					<!--<div class="b_state">邀请成功</div>-->
				<!--</div>-->
			<!--</div>-->

		</div>

		<!-- 邀请中 -->
		<div class="listBox invite2">
			<!--<div class="listDetail">-->
				<!--<div class="list_t cleardrift">-->
					<!--<div class="t_name">admin</div>-->
					<!--<div class="t_time">12-12 10:22</div>-->
				<!--</div>-->
				<!--<div class="list_c cleardrift">-->
					<!--<div class="c_phone">123123123</div>-->
					<!--<div class="c_copy">复制</div>-->
				<!--</div>-->
				<!--<div class="list_b cleardrift">-->
					<!--<div class="b_guanxi"><span>与我关系</span>: 直接</div>-->
					<!--<div class="b_stating">邀请中</div>-->
				<!--</div>-->
			<!--</div>-->


		</div>
	</div>

	<a class="invite-btn" href="{:url('invite')}">
		<button>邀请用户获得收益</button>
	</a>

	<div class="shuoming">
		<div class="cleardrift">
			<img src="/index/assets/close.png" class="close cleardrift" >
		</div>
		<div>{$help.content|raw}</div>
	</div>

<div style="height:70px"></div>
</body>
</html>
<script type="text/javascript" src="/index/js/jquery-3.4.1.min.js"></script>
<script type="text/javascript" src="/index/js/clipboard.min.js"></script>
<script src="/index/js/common.js"></script>
<script>

	// 复制功能
	function copy(){

        var obj = document.getElementsByClassName()("c_phone");
        copyText(obj,obj.innerText);
	}
	$('.tabRight').click(function(){
		$('.shuoming').fadeIn(500)
        $.get('{:url("explain/helpHits",["id"=>$help.id])}','',function(){})

    })
	$('.close').click(function(){
		$('.shuoming').fadeOut(500)
	})


    $(function(){
        var tab = 1;

        //切换tab
        $('.tabs').click(function(){
            var index = $(this).index();
			tab = index+1;
            console.log(index);
            $(this).addClass("on").siblings().removeClass("on");
            $(".listBox").eq(index).addClass("active").siblings().removeClass("active");

            if($('.active').find('.listDetail').length==0){
                getUserList();
			}
        })


        var page = {1:1,2:1}
        var flag = {1:0,2:0};
        var is_end = {1:0,2:0};
        getUserList();

        //获取邀请好友列表
        function getUserList(){

            if ((tab == 1 && "{$count['total1']}"==0) || (tab==2 && "{$count['total2']}"==0)){
                is_end[tab] = 1;
                return;
            }

            $('#load-text'+tab).text('加载中...');
            $.get('{:url("inviteRecord")}',{page:page[tab],type:tab},function(res){

                if(res.code==0){
                    toastFail(res.msg);
                    return;
				}
				var list = res.data.data;

                $('#load-text'+tab).text('');

                for(k in list){
                   var _html ='<div class="listDetail">'

                    _html+=  '<div class="list_t cleardrift">'
                    _html+=  '<div class="t_name">'+list[k].nickname+'</div>'
                    _html+=  '<div class="t_time">'+list[k].create_time+'</div>'
                    _html+='</div>'
                    _html+= '<div class="list_c cleardrift">'
					if(list[k].phone){
                        _html+= '<div class="c_phone">'+list[k].phone+'</div>'

                        _html+=  '<div class="c_copy" onclick="copy">复制</div>'

                    }
                    _html+=  '</div>'
                    _html+=  '<div class="list_b cleardrift">'
					var gx = '';

					if(list[k].pid==res.uid){
					    gx = '直接';
					}else if(list[k].ppid==res.uid){
                        gx = '间接';

                    }
                    _html+= '<div class="b_guanxi"><span>与我关系</span>: '+gx+'</div>'
					if(tab==1){
                        _html+= '<div class="b_state">邀请成功</div>'

                    }else{
                        _html+= '<div class="b_stating">邀请中</div>'

                    }
                    _html+= '</div>'
                    _html+= '</div>'

                    $('.active').append(_html);

                }

                if(res.data.current_page>=last_page){
                    is_end[tab]=1;
                    $('#load-text'+tab).text('已加载全部');

                    return;
                }

                page[tab]++;
                flag[tab] = 0;


            },'json')
        }


        $(window).scroll(function() {

            if(flag[tab]==0 && is_end[tab]==0 ){

                //当时滚动条离底部60px时开始加载下一页的内容
                if (($(window).height() + $(window).scrollTop() + 60) >= $(document).height()) {
                    flag[tab] = 1;

                    getUserList();
                }
            }

        });
    });

</script>
